var Dashboard = function(obj) {
	function getWallModuleString(sId) {
		var propertyId = "";

		switch(sId) {
			case "Communication_Error_Count":
				propertyId = "wall.sensor.communicationerror";
				break;

			case "Configured_Sensors_Count":
				propertyId = "wall.sensor.configured";
				break;

			case "Functional_Error_Count":
				propertyId = "wall.sensor.functionalerror";
				break;

			case "Installed_Sensors_Count":
				propertyId = "wall.sensor.installed";
				break;

			case "Recovered_Sensors_Count":
				propertyId = "wall.sensor.recovered";
				break;

			case "Install_Pending_Sensors_Count":
				propertyId = "wall.sensor.pending";
				break;

			case "Configured_Sensors_Count":
				propertyId = "wall.sensor.configured";
				break;

			case "Reinstated_Sensors_Count":
				propertyId = "wall.sensor.reinstated";
				break;

			case "Stopped_Sensors_Count":
				propertyId = "wall.sensor.stopped";
				break;

			case "Suspended_Sensors_Count":
				propertyId = "wall.sensor.suspended";
				break;

			case "Upgrade_Failed_Sensors_Count":
				propertyId = "wall.sensor.upgrade.failed";
				break;

			case "Upgrade_Pending_Sensors_Count":
				propertyId = "wall.sensor.upgrade.pending";
				break;

			case "Upgraded_Succeeded_Sensors_Count":
				propertyId = "wall.sensor.upgrade.succeeded";
				break;

			case "Deleted_Scans_Count":
				propertyId = "wall.scan.deleted";
				break;
			case "Failed_Scans_Count":
				propertyId = "wall.scan.failed";
				break;

			case "Completed_Scans_Count":
				propertyId = "wall.scan.completed";
				break;

			case "Skipped_Scans_Count":
				propertyId = "wall.scan.skipped";
				break;

			case "Restored_Scans_Count":
				propertyId = "wall.scan.restored";
				break;

			case "Reinstated_Scans_Count":
				propertyId = "wall.scan.reinstated";
				break;

			case "Partially_Completed_Scans_Count":
				propertyId = "wall.scan.partial";
				break;

			case "Suspended_Scans_Count":
				propertyId = "wall.scan.suspended";
				break;
		}

		return getLocaleString(propertyId);
	};

	var WallModuleTypes = {
		DASHBOARD_TASK : "Dashboard_Task",
		ONLINE_REPORT_TASK : "Online_Report_Task",
		STATIC_TASK : "Static_Task"
	};

	var ModuleIds = {
		SCAN_TASK : "SCAN_TASK",
		SENSOR_TASK : "SENSOR_TASK",
		DISCOVERY_SINCE_LAST_LOGIN : "DISCOVERY_SINCE_LAST_LOGIN"
	};

	var WallModules = {
		"AUDIT_LOG_TASK" : {
			title : getLocaleString("wall.audittrail.moduletitle"),
			className : "AuditTrailIcon",
			actionButton : {
				title : getLocaleString("wall.audittrail.actionlink.default"),
				action : "audit"
			},
			listCreateFunction : null
		},
		"ONLINE_REPORTS_TASK" : {
			title : getLocaleString("wall.onlinereports.moduletitle"),
			className : "ReportIcon",
			actionButton : {
				title : getLocaleString("wall.onlinereports.actionlink.default"),
				action : "reports"
			},
			listCreateFunction : null
		},
		"USER_TASK" : {
			title : getLocaleString("wall.users.moduletitle"),
			className : "UserIcon",
			actionButton : {
				title : getLocaleString("wall.users.actionlink.default"),
				action : "users"
			},
			listCreateFunction : null
		},
		"GROUPS_TASK" : {
			title : getLocaleString("wall.groups.moduletitle"),
			className : "RoleIcon",
			actionButton : {
				title : getLocaleString("wall.groups.actionlink.default"),
				action : "groups"
			},
			listCreateFunction : null
		},
		"NOTIFICATIONS_TASK" : {
			title : getLocaleString("wall.notifications.moduletitle"),
			className : "NotificationsIcon",
			actionButton : {
				title : getLocaleString("wall.notifications.actionlink.default"),
				action : "notifications"
			},
			listCreateFunction : null
		},
		"TEMPLATES_TASK" : {
			title : getLocaleString("wall.templates.moduletitle"),
			className : "TemplateIcon",
			actionButton : {
				title : getLocaleString("wall.templates.actionlink.default"),
				action : "templates"
			},
			listCreateFunction : null
		},
		"OFFLINE_REPORTS_TASK" : {
			title : getLocaleString("wall.offlinereports.moduletitle"),
			className : "OfflineReportIcon",
			actionButton : {
				title : getLocaleString("wall.offlinereports.actionlink.default"),
				action : "library"
			},
			listCreateFunction : null
		}
	};

	WallModules[ModuleIds.SCAN_TASK] = {
		title : getLocaleString("wall.scan.moduletitle"),
		className : "ScanIcon",
		actionButton : {
			title : getLocaleString("wall.scan.actionlink.default"),
			action : "scans"
		},
		listCreateFunction : function(oUL) {
			var data = this.config.data;
			var count = 0;
			var strURL = '';

			for(var i in data.embeddedData) {

				/*strURL = basePath + 'scans#/{"filters":{"values":[{"category":"state","from":"' + data.embeddedData[i].linkedData.state + '","opType":"C"}]}}';

				 oUL.append($("<li><a href='" + strURL + "'>" + data.embeddedData[i].embeddedDataValue + " " + getWallModuleString(data.embeddedData[i].embeddedDataId) + "</a></li>"));*/
				oUL.append($("<li>" + data.embeddedData[i].embeddedDataValue + " " + getWallModuleString(data.embeddedData[i].embeddedDataId) + "</li>"));

				if(++count == 5)
					break;
			}

			return oUL;
		}
	};

	WallModules[ModuleIds.SENSOR_TASK] = {
		title : getLocaleString("wall.sensor.moduletitle"),
		className : "SensorIcon",
		actionButton : {
			title : function() {
				if("title" in this.config.data) {
					switch(this.config.data.title) {
						case "ADD_SENSOR":
							return getLocaleString("wall.sensor.actionlink.firsttime");
							break;

						case "NO_SENSOR":
							this.actionButton.action = null;
							return getLocaleString("wall.sensor.actionlink.nosensor");
							break;
					}
				}

				return getLocaleString("wall.sensor.actionlink.default");
			},
			action : "sensors"
		},
		listCreateFunction : function(oUL) {
			var data = this.config.data;
			var count = 0;
			var strURL = "";

			for(var i in data.embeddedData) {

				//strURL = basePath + 'sensors#/{"filtersSelected":{"' + data.embeddedData[i].linkedData.state + '":"true"}}';
				/* strURL = basePath + 'sensors#/{"filters":{"values":[{"category":"status","from":"' + data.embeddedData[i].linkedData.state + '","opType":"C"}]}}'; */

				//oUL.append($("<li><a href='" + strURL + "'>" + data.embeddedData[i].embeddedDataValue + " " + getWallModuleString(data.embeddedData[i].embeddedDataId) + "</a></li>"));
				//IDC - Raghu_Nair@Symantec.com - Removed the links.
				oUL.append($("<li>" + data.embeddedData[i].embeddedDataValue + " " + getWallModuleString(data.embeddedData[i].embeddedDataId) + "</li>"));

				if(++count == 5)
					break;
			}

			return oUL;
		}
	};

	WallModules[WallModuleTypes.DASHBOARD_TASK] = {
		title : getLocaleString("wall.dashboard.moduletitle"),
		className : "dashboardIcon",
		embed : "../images/dashboard_graphic.svg",
		embedAlt : "../images/dashboard_graphic.jpg",
		actionButton : {
			action : "dashboard"
		},
		listCreateFunction : null
	};

	WallModules[WallModuleTypes.ONLINE_REPORT_TASK] = {
		title : getLocaleString("wall.onlinereports.moduletitle"),
		className : "ReportIcon",
		actionButton : {
			action : "reports"
		},
		listCreateFunction : null
	};

	var DashboardModules = {
		"MSSL_CERTS" : {
			title : getLocaleString("dashboard.module.msslcerts")
		},
		"CERTS_BY_KEY_SIZE" : {
			title : getLocaleString("dashboard.module.certsbykeysize")
		},
		"CERTS_BY_CA" : {
			title : getLocaleString("dashboard.module.certsbyca")
		},
		"CERTS_BY_SENSOR_NAME" : {
			title : getLocaleString("dashboard.module.certsbysensorname")
		},
		"CERTS_BY_ORGANIZATION" : {
			title : getLocaleString("dashboard.module.certsbyorganization")
		},
		"CERTS_BY_PORT" : {
			title : getLocaleString("dashboard.module.certsbyport")
		},
		"NEW_CERTS_FOUND" : {
			title : getLocaleString("dashboard.module.newcertsfound")
		},
		"CERTS_REMOVED_FROM_CDA" : {
			title : getLocaleString("dashboard.module.certsremovedfromcda")
		},
		"CERTS_BY_ALGORITHM" : {
			title : getLocaleString("dashboard.module.certsbyalgorithm")
		},
		"SENSOR_HEALTH" : {
			title : getLocaleString("dashboard.module.sensorhealth")
		},
		"CERTS_BY_SERVER_TYPE" : {
			title : getLocaleString("dashboard.module.certsbyservertype")
		},
		"HOSTS_BY_OS" : {
			title : getLocaleString("dashboard.module.hostsbyos")
		},
		"EXPIRING_CERTIFICATES_BY_DAYS" : {
			title : getLocaleString("dashboard.module.expiringcertificatesbydays")
		},
		"VERISIGN_UNITS_AVAILABLE" : {
			title : getLocaleString("dashboard.module.verisignunitsavailable")
		},
		"UNITS_CONSUMPTION_FORECAST" : {
			title : getLocaleString("dashboard.module.unitsconsumptionforecast")
		},
		"EV_VS_NON_EV" : {
			title : getLocaleString("dashboard.module.evvsnonev")
		},
		"UNITS_FORECAST" : {
			title : getLocaleString("dashboard.module.unitsforecast")
		},
		"INSTALLATION_STATUS" : {
			title : getLocaleString("dashboard.module.installationstatus")
		},
		"CERTS_BY_SSL_SCORE" : {
			title : getLocaleString("dashboard.module.certsbysslscore")
		}
	};

	DashboardModules[ModuleIds.DISCOVERY_SINCE_LAST_LOGIN] = {
		title : getLocaleString("dashboard.module.discoverysincelastlogin")
	};

	var objDashboard = this;
	var panels = [];
	var pages = [];
	var renderObj = [];
	var graphDataForAllPages = [];
	var basePath = "/console/view/";
	var isWall = (document.location.pathname.split("/")[3] == "wall");

	this.data = null;
	this.node = null;
	this.paginationContainer = null;
	this.fit = isWall ? [3, 3] : [4, 2];
	this.totalPageCount = 0;

	this.getNavigation = function() {
		return Navigation;
	};

	this.getNode = function() {
		return objDashboard.node;
	};

	this.getPage = function(index) {
		if(index)
			return pages[index];
	};

	this.getPanel = function(id) {
		var oPanel = null;

		if(id) {
			$.each(panels, function(tempIndex, tempPanel) {
				if(tempPanel.getId() == id) {
					oPanel = tempPanel;
					return false;
				}
			});
		}

		return oPanel;
	};

	this.addPanel = function(oPanel) {
		panels.push(oPanel);
	};

	this.create = function() {
		$.each(new Array(this.totalPageCount), function(pageIndex, oPage) {
			objDashboard.getNavigation().addNavDot((pageIndex == 0) ? true : false);

			var panelIndex = 0;
			var oPlaceholderPanel = null;
			var oPage = {
				node : $("<div></div>").addClass("dashboardPageContainer")
			};

			oPage.node.css("left", (pageIndex * 100) + "%");

			pages.push(oPage);

			$.each(new Array(objDashboard.fit[1]), function(rowIndex, row) {
				$.each(new Array(objDashboard.fit[0]), function(colIndex, col) {
					(new PlaceholderPanel({
						position : {
							page : pageIndex,
							index : panelIndex++
						}
					})).create();
				});
			});

			objDashboard.getNode().append(oPage.node);
		});

		$.each(panels, function(tempIndex, tempPanel) {
			tempPanel.create();
		});
		return objDashboard.getNode();
	};

	$.extend(true, this, obj);

	if(this.data && typeof this.data == "function")
		this.data = this.data();

	function Panel(obj) {
		var title = "";
		var id = "";
		var page = null;
		var node = $("<div></div>").addClass("Panel");

		this.config = obj;
		this.action = "";
		this.className = "";

		this.getNode = function() {
			return node;
		};

		this.getPage = function() {
			return page;
		};

		this.getId = function() {
			return id;
		};

		this.setTitle = function(sTitle) {
			title = sTitle;
		};

		this.getTitle = function() {
			return title;
		};
		if(obj) {
			$.extend(true, this, obj);

			if(obj.title)
				this.setTitle(obj.title);

			if(obj.id) {
				id = obj.id;
			}
		}
	}


	Panel.prototype.create = function() {
		var oPanel = this.getNode();
		var oAppendTo = pages[this.position.page].node;
		var oPlaceholderPanel = oAppendTo.children("div:eq(" + this.position.index + ")");

		if(oPlaceholderPanel && oPlaceholderPanel.length)
			oPlaceholderPanel.replaceWith(oPanel);
		else
			oAppendTo.append(oPanel);

		return oPanel;
	};

	Panel.prototype.triggerAction = function() {
		if(this.action && typeof this.action == "function")
			this.action();
	};
	function PlaceholderPanel(obj) {
		Panel.call(this, obj);
	}


	PlaceholderPanel.prototype = new Panel;
	PlaceholderPanel.prototype.constructor = PlaceholderPanel;

	PlaceholderPanel.prototype.create = function() {
		var oHTML = Panel.prototype.create.apply(this).addClass("PlaceholderPanel");
		return oHTML;
	};
	function WallPanel(obj) {
		if(obj && obj.data && obj.data.identifiers.id)
			obj.id = obj.data.identifiers.id;

		Panel.call(this, obj);
	}


	WallPanel.prototype = new Panel;
	WallPanel.prototype.constructor = WallPanel;

	WallPanel.prototype.create = function() {
		var oHTML = Panel.prototype.create.apply(this);

		oHTML.html('<div class="HeaderContainer"><h2></h2></div><div class="Content"><div class="SubContentWrapper"><div class="Icon"></div></div></div><div class="Footer"><div><a></a></div></div>');
		oHTML.find("h2").html(this.getTitle());
		oHTML.find(".Icon").addClass(this.className);

		if(this.actionButton) {
			var oA = $("<a></a>");

			if( typeof this.actionButton.title == "function")
				oA.html(this.actionButton.title.call(this));
			else
				oA.html(this.actionButton.title);

			if(this.actionButton.action) {
				if( typeof this.actionButton.action == "function") {
					var oThis = this;
					var oFncAction = this.actionButton.action;

					oA.attr("href", "javascript:void(0);").click(function() {
						return oFncAction.call(oThis);
					});
					if(this instanceof NonStatsPanel) {
						oHTML.find(".Icon").click(function() {
							oA.click();
						});
					}
				} else {
					oA.attr("href", basePath + this.actionButton.action);
					//oA.click(function(){NoPrompt(); });
					if(this instanceof NonStatsPanel) {
						oHTML.find(".Icon").click(function() {

							//NoPrompt();
							document.location.href = oA.attr("href");
						});
					}
				}
			} else {
				oA = oA.html();
			}

			if(this instanceof StatsPanel) {
				oHTML.find(".Footer div").append(oA);
			} else if(this instanceof NonStatsPanel) {
				oHTML.find(".SubContentWrapper").append(oA);
			}
		}

		if("message" in this.config.data) {
			var sBubbleId = this.config.data.message;
			var sMsg = ( sBubbleId in Lookup.wall.bubbles) ? Lookup.wall.bubbles[sBubbleId] : "No Message";

			oHTML.qtip({
				prerender : false,
				content : {
					text : sMsg + "<div class='wallFirstTimeBlurbClose'></div>"
				},
				show : false,
				hide : false,
				position : {
					container : pages[this.position.page].node,
					corner : {
						target : 'bottomMiddle',
						tooltip : 'topMiddle'
					},
					adjust : {
						x : -261,
						y : -70
					}
				},
				style : {
					textAlign : 'left',
					background : '#fafafa',
					color : '#000000',
					padding : '1em',
					border : {
						radius : 5,
						color : '#5482ab'
					},
					width : {
						min : 300,
						max : 300
					},
					classes : {
						content : "wallFirstTimeBlurb"
					},
					tip : {
						corner : "topMiddle"
					}
				}

			});

			oHTML.qtip("api").elements.content.find(".wallFirstTimeBlurbClose:eq(0)").click(function() {
				(new CommandCloseWallBubble()).execute(sBubbleId, function() {
					oHTML.qtip("hide");
				});
			});

			oHTML.qtip("show");
		}

		return oHTML;
	};
	function InversePanel(obj) {
		WallPanel.call(this, obj);
	}


	InversePanel.prototype = new WallPanel;
	InversePanel.prototype.constructor = InversePanel;

	InversePanel.prototype.create = function() {
		var oHTML = WallPanel.prototype.create.apply(this).addClass("InversePanel");
		return oHTML;
	};
	function ThumbnailPanel(obj) {
		InversePanel.call(this, obj);
	}


	ThumbnailPanel.idCount = 0;
	ThumbnailPanel.prototype = new InversePanel;
	ThumbnailPanel.prototype.constructor = ThumbnailPanel;

	ThumbnailPanel.prototype.create = function() {
		var oHTML = InversePanel.prototype.create.apply(this).addClass("ThumbnailPanel");

		if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0")) {
			oHTML.find(".Content").html('<object id="thumbnailPanel' + ThumbnailPanel.idCount + '" data="' + this.embed + '" type="image/svg+xml" style="width:100%;height:100%;"/></object><div style="position:absolute;top:0px;left:0px;height:100%;width:100%;cursor:pointer;"></div>');

			if(this.actionButton.action) {
				if( typeof this.actionButton.action == "function") {
					var oThis = this;
					var oFncAction = this.actionButton.action;

					oHTML.click(function() {
						return oFncAction.call(oThis);
					});
				} else {
					var objThis = this;

					oHTML.click(function() {
						document.location.href = basePath + objThis.actionButton.action;
					});
				}
			}
		} else {
			if(this.embedAlt) {
				oHTML.find(".Footer").remove();
				oHTML.find(".SubContentWrapper").html('<img src="' + this.embedAlt + '" width="100%" height="100%" border="0"></img>');
			}

			if(this.actionButton.action) {
				if( typeof this.actionButton.action == "function") {
					var oThis = this;
					var oFncAction = this.actionButton.action;

					if(oHTML.find(".Icon").length) {
						oHTML.find(".Icon").click(function() {
							return oFncAction.call(oThis);
						});
					} else if(oHTML.find("a").length) {
						oHTML.find("a").click(function() {
							return oFncAction.call(oThis);
						});
					}
				} else {
					var objThis = this;

					oHTML.click(function() {
						document.location.href = basePath + objThis.actionButton.action;
					});
				}
			}
		}

		return oHTML;
	};
	function NonStatsPanel(obj) {
		WallPanel.call(this, obj);
	}


	NonStatsPanel.prototype = new WallPanel;
	NonStatsPanel.prototype.constructor = NonStatsPanel;

	NonStatsPanel.prototype.create = function() {
		var oHTML = WallPanel.prototype.create.apply(this).addClass("NonStatsPanel").find(".Footer").remove();

		return oHTML;
	};
	function StatsPanel(obj) {
		WallPanel.call(this, obj);

		this.listCreateFunction = (obj.listCreateFunction) ? obj.listCreateFunction : null;
	}


	StatsPanel.prototype = new WallPanel;
	StatsPanel.prototype.constructor = StatsPanel;

	StatsPanel.prototype.create = function() {
		var oHTML = WallPanel.prototype.create.apply(this);
		var oData = $('<div class="Data"></div>');
		var oUL = $("<ul></ul>");

		if(this.listCreateFunction)
			this.listCreateFunction.call(this, oUL);

		oData.append(oUL);

		oHTML.find(".Content").append(oData);

		return oHTML;
	};
	function DashboardPanel(obj) {
		Panel.call(this, obj);
	}


	DashboardPanel.prototype = new Panel;
	DashboardPanel.prototype.constructor = DashboardPanel;

	DashboardPanel.prototype.create = function() {
		var oHTML = Panel.prototype.create.apply(this).html((this.config && this.config.data && this.config.data.title) ? this.config.data.title : this.id);
		return oHTML;
	};
	function ChartingPanel(obj) {
		Panel.call(this, obj);
	}


	ChartingPanel.prototype = new Panel;
	ChartingPanel.prototype.constructor = ChartingPanel;

	ChartingPanel.prototype.create = function() {
		var oHTML = Panel.prototype.create.apply(this).addClass("ChartPanel").html('<div class="filterSearchFieldIcon"></div><div id="' + this.id + '" class="ChartContainer"></div>');
		var oZoom = {
			graphId : this.id,
			data : null
		};

		oHTML.find(".filterSearchFieldIcon").click(function() {
			if(oZoom.data == null) {
				var graphDataReq = {};
				var graphPrefs = [];
				var pref = {};
				pref.graphId = {};
				pref.graphId.defaultId = oZoom.graphId;
				pref.body = {};
				pref.body.selectedFilters = {};
				graphPrefs.push(pref);
				graphDataReq.graphPrefs = graphPrefs;
				oZoom.data = ServiceManager.getGraphdata(graphDataReq);
			}

			new zoomView(oZoom);
		});
		return oHTML;
	};
	function DiscoverySinceLastLoginPanel(obj) {
		DashboardPanel.call(this, obj);
	};


	DiscoverySinceLastLoginPanel.prototype = new DashboardPanel;
	DiscoverySinceLastLoginPanel.prototype.constructor = DiscoverySinceLastLoginPanel;

	DiscoverySinceLastLoginPanel.prototype.create = function() {
		var oHTML = DashboardPanel.prototype.create.apply(this);

		if(this.config && this.config.data) {
			if(this.config.data.discoverySinceLastLogin) {
				for(var i in this.config.data.discoverySinceLastLogin) {
					oHTML.append("<div>" + this.config.data.discoverySinceLastLogin[i] + "   " + i + "</div>");
				}
			}
		}
	}
	if(isWall && typeof this.data != 'undefined' && typeof this.data.Response != 'undefined' && this.data.Response.wallPages) {
		$.each(this.data.Response.wallPages, function(pageIndex, oWallPage) {
			objDashboard.totalPageCount++;

			$.each(oWallPage.wallTasks, function(panelIndex, oTask) {
				var oPanel = null;
				var oPanelDefinition = {
					data : oTask
				};

				oPanelDefinition.position = {
					page : pageIndex,
					index : panelIndex
				};

				if(oTask == null) {
					oPanel = new Panel(oPanelDefinition);
				} else {
					if(oTask.type == WallModuleTypes.STATIC_TASK) {
						if(WallModules[oTask.identifiers.id]) {
							$.extend(true, oPanelDefinition, WallModules[oTask.identifiers.id]);

							if(oPanelDefinition.listCreateFunction == null || !("embeddedData" in oTask) || oTask.embeddedData == null || oTask.embeddedData.length == 0) {
								oPanel = new NonStatsPanel(oPanelDefinition);
							} else
								oPanel = new StatsPanel(oPanelDefinition);
						}
					} else if(oTask.type == WallModuleTypes.DASHBOARD_TASK) {
						if(WallModules[oTask.type]) {
							$.extend(true, oPanelDefinition, WallModules[oTask.type]);

							oPanelDefinition.title = oTask.identifiers.name;
							oPanelDefinition.actionButton.action = (function() {
								var strURL = 'dashboard';
								strURL += '?';

								for(var i in oTask.linkData) {
									strURL += i + "=" + oTask.linkData[i] + "&amp;";
								}

								return strURL;
							})();
						}
						oPanel = new ThumbnailPanel(oPanelDefinition);

					} else if(oTask.type == WallModuleTypes.ONLINE_REPORT_TASK) {
						if(WallModules[oTask.type]) {
							$.extend(true, oPanelDefinition, WallModules[oTask.type]);

							oPanelDefinition.title = oTask.identifiers.name;
							oPanelDefinition.actionButton.action = 'reports?customID=' + oTask.identifiers.customID + "&amp;defaultID=" + oTask.identifiers.defaultID;
						}
						oPanel = new ThumbnailPanel(oPanelDefinition);
					}

					objDashboard.addPanel(oPanel);
				}
			});
		});
	} else if( typeof this.data != 'undefined' && typeof this.data.body != 'undefined' && typeof this.data.body.graphIdsPerPage != 'undefined') {

		$.each(this.data.body.graphIdsPerPage, function(pageIndex, oPage) {

			var graphDataReq = {};
			var graphPrefs = [];

			//oPage is each page with a list of graphIds

			for(var i = 0; i < oPage.length; i++) {

				var pref = {};

				pref.graphId = {};

				//oPage[i] is Page i of Dashboard. oPage[i].defaultId will return a list of defaultIds on that page
				pref.graphId.defaultId = oPage[i].defaultId;

				pref.body = {};
				pref.body.selectedFilters = {};
				graphPrefs.push(pref);
			}

			graphDataReq.graphPrefs = graphPrefs;
			//graphData is a Map. This can be checked from serialize.js, SerializeManager.serializeGetGraphDataResponse returns a Map
			var graphData = ServiceManager.getGraphdata(graphDataReq);
			objDashboard.totalPageCount++;

			$.each(oPage, function(panelIndex, oModule) {
				var moduleId = oModule.defaultId;
				// List of defaultIds on Page "i"
				var oPanel = null;
				var oPanelDefinition = {
					data : oModule
				};

				oPanelDefinition.position = {
					page : pageIndex,
					index : panelIndex
				};
				oPanelDefinition.id = moduleId;

				// Check if graphData Map contains the key moduleId
				try {
					if(graphData[moduleId]) {

						// If key moduleId is present, get the response for that particular graph
						var moduleData = graphData[moduleId];

						// Form a key-value pair with value same as key
						renderObj[moduleId] = moduleId;

						// Key value pair with key as defaultId and value as the graph response for the defaultId
						graphDataForAllPages[moduleId] = moduleData;

						if(moduleId == ModuleIds.DISCOVERY_SINCE_LAST_LOGIN) {
							$.extend(oPanelDefinition.data, moduleData);
							oPanel = new DiscoverySinceLastLoginPanel(oPanelDefinition);
							objDashboard.addPanel(oPanel);
						} else {
							oPanel = new ChartingPanel(oPanelDefinition);
							objDashboard.addPanel(oPanel);
						}
					}
				} catch(e) {

				}

			});
			//generateChartFromJSON(graphData, 1, renderObj);
		});
	} else {
		/* No data available. User shouldn't be here. Redirect to wall */
		document.location.href = 'wall';
	}

	var Navigation = (function() {
		var node = objDashboard.paginationContainer;
		var selectedNavDot = null;
		var navObj = {
			navDots : [],
			addNavDot : function(isSelected) {
				navObj.navDots.push((new NavDot(isSelected)).create());
			},
			getNode : function() {
				return node;
			},
			getSelectedIndex : function() {
				return (selectedNavDot != null) ? selectedNavDot.getIndex() : 0;
			}
		};

		function NavDot(isSelected) {
			var thisNavDot = this;
			var selected = isSelected;
			var node = $("<li></li>");
			var index = NavDot.indexCount++;

			this.getNode = function() {
				return node;
			};

			this.isSelected = function(val) {
				if(arguments.length) {
					selected = val;

					if(selected == true) {
						if(selectedNavDot)
							selectedNavDot.isSelected(false);
						selectedNavDot = thisNavDot;

						/* Set deep link */
						var aPath = $.address.pathNames();
						if( typeof aPath[0] == "undefined" || aPath[0] == "page") {
							/* No Dashboard ID because it's page one */
							$.address.value('page/' + (index + 1).toString());
						} else if(!isNaN(parseInt(aPath[0]))) {
							/* Dashboard ID is present, so maintain it */
							$.address.value(aPath[0] + '/page/' + (index + 1).toString());
						} else {
							//Messaging.show({type:"Debug", obj:aPath, msg:"Deep-linking error in dashboardObject.js"});
						}

						/* Update page title to match deep link
						 * QUESTION: Is this the right place to do this?
						 * */

						/* Check dropdown menu for dashboard name, otherwise parse url */
						var path, moduleName, dashName, prefix = '', jEle = $('#dashboardSelect option:selected');

						if(jEle.val() > 501) {
							prefix = getLocaleString('dashboard.title') + ' ';
						}
						/* dashName = prefix + jEle.text(); */
						dashName = getLocaleString('dashboard.title');

						if(!dashName || (dashName == '')) {
							path = $.address.baseURL();
							moduleName = path.substr(path.lastIndexOf('/') + 1);
							dashName = moduleName.charAt(0).toUpperCase() + moduleName.slice(1);
						}

						if(index > 0) {
							dashName += ' ' + getLocaleString('history.page') + ' ' + (index + 1).toString();
						}
						CommandUpdateTitle(dashName);
					}
				}

				return selected;
			};

			this.getIndex = function() {
				return index;
			};
		}


		NavDot.indexCount = 0;

		NavDot.prototype.create = function() {
			var oNavDot = this;
			var node = this.getNode();
			var oDiv = node.append($("<div></div>").addClass("dashboardPaginationIcon"));

			node.addClass((this.isSelected() ? "selected" : "unselected"));

			node.click(function() {
				if(selectedNavDot == oNavDot)
					return;

				var dashboardNode = objDashboard.getNode();
				var intScrollLeft = dashboardNode.width() * navObj.getSelectedIndex();

				$.each(dashboardNode.children(), function(index, oDiv) {
					$(oDiv).css("left", (dashboardNode.width() * index) + "px");
					$(oDiv).show();
				});

				dashboardNode.scrollLeft(intScrollLeft);
				dashboardNode.scrollTo(dashboardNode.width() * oNavDot.getIndex(), {
					duration : 500,
					axis : 'x',
					easing : "swing",
					onAfter : function() {
						/*$.each(dashboardNode.children(), function(index, oDiv){
						 if(index != oNavDot.getIndex()){
						 $(oDiv).hide();
						 }
						 });

						 dashboardNode.children("div:eq(" + oNavDot.getIndex() + ")").css("left", "0px");
						 dashboardNode.scrollLeft(0);*/
					}
				});

				$.each(navObj.navDots, function(index, oNavDot) {
					oNavDot.getNode().removeClass("selected").addClass("unselected");
				});

				node.removeClass("unselected").addClass("selected");

				oNavDot.isSelected(true);
			});

			navObj.getNode().find("ul:eq(0)").append(node);

			return this;
		};
		return navObj;
	})();

	if(obj.node) {
		this.create();
	} else
		alert("constructor Dashboard requires node");

	$(document).ready(function() {
		objDashboard.getNode().scrollLeft(0);

		function setPanelSizing() {
			var marginWidthPercentage = 100 * ((12 * (objDashboard.fit[0] + 1)) / objDashboard.getNode().width());
			var marginHeightPercentage = 100 * ((12 * (objDashboard.fit[1])) / objDashboard.getNode().height());
			var panelWidthPercentage = (100 - marginWidthPercentage) / objDashboard.fit[0];
			var panelHeightPercentage = (100 - marginHeightPercentage) / objDashboard.fit[1];

			objDashboard.getNode().find(".Panel").css("width", panelWidthPercentage + "%");
			objDashboard.getNode().find(".Panel").css("height", panelHeightPercentage + "%");
		}


		$(window).bind("resize", setPanelSizing);

		setPanelSizing();

		if(!isWall)
			generateChartFromJSON(graphDataForAllPages, 1, renderObj);
	});
	return objDashboard;
};
